﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.DOM.CSS.SAC.Selectors
{
    #region Using Statements

    using KLF.Lib.Browser.DOM.HTML;

    #endregion

    abstract public class BinarySelector : Selector
    {
        public BinarySelector(Selector _l, Selector _r)
        {
            Left = _l;
            Right = _r;
        }

        public Selector Left { get; set; }

        public Selector Right { get; set; }

        public override bool Matches(HTMLElement e)
        {
            if (Left != null && e.Parent != null && Left.Matches(e.Parent as HTMLElement))
            {
                if (Right != null)
                    return Right.Matches(e);
            }
            return false;
        }
    }
}
